//
// Created by liushuai on 2021/1/13.
//

#include "threeOrders.h"

void preTraval(TreeNode* root, vector<int>& result) {
  if (root) {
    result.push_back(root->val);
    preTraval(root->left, result);
    preTraval(root->right, result);
  }
}
void midTraval(TreeNode* root, vector<int>& result) {
  if (root) {
    midTraval(root->left, result);
    result.push_back(root->val);
    midTraval(root->right, result);
  }
}
void postTraval(TreeNode* root, vector<int>& result) {
  if (root) {
    postTraval(root->left, result);
    postTraval(root->right, result);
    result.push_back(root->val);
  }
}
vector<vector<int>> threeOrders(TreeNode* root) {
  vector<int> pre;
  vector<int> mid;
  vector<int> post;
  vector<vector<int>> result;

  preTraval(root, pre);
  midTraval(root, mid);
  postTraval(root, post);
  result.push_back(pre);
  result.push_back(mid);
  result.push_back(post);
  return result;
}